package cn.gson.springboot.controller;

import cn.gson.springboot.model.pojos.InventoryFlow;
import cn.gson.springboot.model.service.InventoryFlowService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class InventoryFlowController {
    @Autowired
    InventoryFlowService invFlowService;

    @RequestMapping("/inv-flow-list")
    @ResponseBody
    public Map<String,Object> invFlowList(Integer page,Integer size,Integer warId,Integer value,Integer num,String content){
        Page<Object> objects = PageHelper.startPage(page, size);
        List<InventoryFlow> inv = invFlowService.selectInvFlow(warId,value,num,content);
        Map<String,Object> map = new HashMap<>();
        map.put("rows",inv);
        map.put("total",objects.getTotal());
        return map;
    }

    @RequestMapping("/save-inventoryFlow")
    @ResponseBody
    public void saveInventoryFlow(@RequestBody InventoryFlow inventoryFlow){
        invFlowService.saveInventoryFlow(inventoryFlow);
    }

}
